Conversation
| "log" | ||
|
|
||
| "github.com/tokopedia/code-review-workshop/database" | ||
| redislib "github.com/tokopedia/code-review-workshop/redis" |
There was a problem hiding this comment.
import lebih baik di rapihkan antara external dan internal code
There was a problem hiding this comment.
| redislib "github.com/tokopedia/code-review-workshop/redis" | |
| "github.com/tokopedia/code-review-workshop/database" | |
| redislib "github.com/tokopedia/code-review-workshop/redis" | |
| "github.com/tokopedia/sqlt" |
| span, ctx := tracer.StartSpanFromContext(ctx) | ||
| defer span.Finish() | ||
|
|
||
| if nim != 0 && mapel_id != 0 { |
There was a problem hiding this comment.
bisa di buat switch case dan di dalamnya masuk2in
-GetNilaiSiswaByID
-GetNilaiSiswaBySekolah
-GetNilaiSiswaSemuaSekolah
lalu baru di luar untuk proses
- GetDetailSekolah dan mappingGetNilaiSiswa
| "github.com/tokopedia/tokopoints/tracer" | ||
| ) | ||
|
|
||
| func GetNilaiSiswa(ctx context.Context, nim int64, sekolah, kelas string, mapel_id int64) (resp GetNilaiSiswaResponse, err error) { |
There was a problem hiding this comment.
parameter sebaiknya di bikin sebuah struct yang baru
| import ( | ||
| "context" | ||
|
|
||
| nilai "github.com/tokopedia/code-review-workshop/core/nilai" |
There was a problem hiding this comment.
import external code dipisah dengan import dari dalam service
|
|
||
| func (s *server) GetNilaiSiswa(ctx context.Context, req *pb.GetNilaiSiswaRequest) (resp *pb.GetNilaiSiswaResponse, err error) { | ||
|
|
||
| if req.sekolah == "" { |
There was a problem hiding this comment.
mungkin pake function Get() dari grpc untuk lebih aman
| req.sekolah = "semua" | ||
| } | ||
|
|
||
| nilai, err := mnilai.GetNilaiSiswa(req.nim, req.sekolah, req.kelas, mapel_id) |
There was a problem hiding this comment.
menggunakan function Get() dari GRPC
| var err error | ||
| db, err = database.Get(database.PromoCatalog) | ||
| if err != nil { | ||
| log.Printf("Cannot connect to DB. %+v", err) |
There was a problem hiding this comment.
lebih baik log.Fatal kah? takutnya ketika servicenya jalan dan tidak bisa ke db jadi error
|
|
||
| const ( | ||
| // Collection queries | ||
| QueryGetNilaiSiswaByID = `select nim, mapel_id, nilai, sekolah, kelas |
No description provided.